package com.czk.controller;

import com.czk.model.hosp.Hospital;
import com.czk.service.HospitalService;
import com.czk.vo.hosp.HospitalQueryVo;
import com.czk.yygh.common.result.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Map;

/**
 * @Author:ChenZhangKun
 * @Date: 2021/11/12 21:20
 */
@RestController
@RequestMapping("/admin/hosp/hospital")
//@CrossOrigin
@Api(tags = "医院管理")
public class HospitalController {
    @Resource
    private HospitalService hospitalService;

    @ApiOperation(value = "查询医院接口")
    @GetMapping("/list/{page}/{limit}")
    public Result listHosp(@PathVariable("page") Integer page, @PathVariable("limit") Integer limit, HospitalQueryVo hospitalQueryVo) {
        Page pageModel = hospitalService.selectHospPage(page, limit, hospitalQueryVo);
        return Result.ok(pageModel);
    }

    @ApiOperation("更新医院状态")
    @GetMapping("/updateHospStatus/{id}/{status}")
    public Result updateHospStatus(@PathVariable("id") String id, @PathVariable("status") Integer status) {
        hospitalService.updateHospStatus(id, status);
        return Result.ok();
    }

    @ApiOperation(value = "医院详情信息")
    @GetMapping("/showHospDetail/{id}")
    public Result showHospDetails(@PathVariable("id") String id) {
        Map<String,Object> map = hospitalService.getHospById(id);
        return Result.ok(map);
    }
}
